<?php
class UserForm extends Zend_Form {
    public function __construct($options = null) 
    {
    	$baseurl 		= new MHDEV_View_Helper_BaseUrl();
    	$translation	= Zend_Registry::get('lang');
    	
        parent::__construct($options);
        
        $this->setName('profile_edit');
        
        // Username
        $username = new Zend_Form_Element_Text('username');
        $username->setLabel($translation->_('admin_user_username'));
        $username->setRequired(true);
        $username->setErrorMessages(array(
            0 => $translation->_('error_register_username'),
        ));
        $username->setDescription($translation->_('admin_user_dusername'));
        
        
        // Mail
        $mail = new Zend_Form_Element_Text('mail');
        $mail->setLabel($translation->_('admin_user_mail'));
        $mail->addFilter('StringToLower');
        $mail->setDescription($translation->_('admin_user_dmail'));

        // Password
        $password = new Zend_Form_Element_Password('password');
		$password->setLabel($translation->_('admin_user_newpassword'));
		$password->setRequired(false);
		$password->addFilter('StringTrim');
		$password->addValidator('StringLength', true, array(6,20));
		$password->setErrorMessages(array(
            'isEmpty' => $translation->_('error_register_password'),
			'stringLengthTooShort' 	=> $translation->_('error_register_password_2'),
            'stringLengthTooLong'	=> $translation->_('error_register_password_3'),
        ));
        $password->setDescription($translation->_('admin_user_dpassword'));
		
        // role
        $role = new Zend_Form_Element_Text('role');
        $role->setLabel($translation->_('admin_user_role'));
        $role->setDescription($translation->_('admin_user_drole'));
        
        // language
        $language = new Zend_Form_Element_Select('language');
        $language->setLabel($translation->_('admin_user_language'));
        $language->setDescription($translation->_('admin_user_dlanguage'));
        $language->addMultiOption('en', 'English');
        $language->addMultiOption('de', 'German');
        
        // Forename
        $forename = new Zend_Form_Element_Text('forename');
        $forename->setLabel($translation->_('admin_user_forename'));
        $forename->setDescription($translation->_('admin_user_dforename'));
        
        // Lastname
        $lastname = new Zend_Form_Element_Text('lastname');
        $lastname->setLabel($translation->_('admin_user_lastname'));
        $lastname->setDescription($translation->_('admin_user_dlastname'));
        
        // City
        $city = new Zend_Form_Element_Text('city');
        $city->setLabel($translation->_('admin_user_city'));
        $city->setDescription($translation->_('admin_user_dcity'));
        
        // Zip
        $zip = new Zend_Form_Element_Text('zip');
        $zip->setLabel($translation->_('admin_user_zip'));
        $zip->setDescription($translation->_('admin_user_dzip'));
        
        // Date of birth
        $dateofbirth = new Zend_Form_Element_Text('date_of_birth');
        $dateofbirth->setLabel($translation->_('admin_user_dateofbirth'));
        $dateofbirth->setDescription($translation->_('admin_user_ddateofbirth'));
        
        // Homepage
        $homepage = new Zend_Form_Element_Text('homepage');
        $homepage->setLabel($translation->_('admin_user_homepage'));
        $homepage->setDescription($translation->_('admin_user_dhomepage'));
        
        // signature
        $signature = new Zend_Form_Element_Textarea('signature');
		$signature->setLabel($translation->_('admin_user_signature'));
		$signature->setDescription($translation->_('admin_user_dsignature'));
		$signature->addFilter('StringTrim');
		$signature->setAttrib('rows','5');
		$signature->setAttrib('cols','30');
		$signature->setErrorMessages(array(
            0 => $translation->_('register_error_signature'),
        ));
        
        // Threads per page
        $threadspp = new Zend_Form_Element_Select('threads_per_page');
        $threadspp->setLabel($translation->_('admin_user_threadspp'));
        $threadspp->setDescription($translation->_('admin_user_dthreadspp'));
        $threadspp->addMultiOption('10', '10');
        $threadspp->addMultiOption('20', '20');
        $threadspp->addMultiOption('50', '50');
        $threadspp->addMultiOption('100', '100');
        $threadspp->setDescription($translation->_('register_dthreadspp'));
        
        // Posts per page
        $postspp = new Zend_Form_Element_Select('posts_per_page');
        $postspp->setLabel($translation->_('admin_user_postspp'));
        $postspp->addMultiOption('10', '10');
        $postspp->addMultiOption('20', '20');
        $postspp->addMultiOption('50', '50');
        $postspp->addMultiOption('100', '100');
        $postspp->setDescription($translation->_('admin_user_dpostspp'));
        
		// layout
		$layout	= new Zend_Form_Element_Select('layout');
		$layout->setRegisterInArrayValidator(false);
		$layout->setLabel($translation->_('admin_user_layout'));
        $layout->setDescription($translation->_('admin_user_dlayout'));
        
        // groups
		$groups = new Zend_Form_Element_Select('group_uid');
		$groups->setRegisterInArrayValidator(false);
		$groups->setLabel($translation->_('admin_user_groups'));
		$groups->setDescription($translation->_('admin_user_dgroups'));
		$groups->setRequired(false);
		
		// activationcode
        $activation_code = new Zend_Form_Element_Text('activation_code');
        $activation_code->setLabel($translation->_('admin_user_activation'));
        $activation_code->setDescription($translation->_('admin_user_dactivation'));
		
        // is active
		$is_active = new Zend_Form_Element_Checkbox('is_active');
		$is_active->setLabel($translation->_('admin_user_active'));
		$is_active->setDescription($translation->_('admin_user_dactive'));
		
		// delete
		$delete = new Zend_Form_Element_Checkbox('is_deleted');
		$delete->setLabel($translation->_('admin_user_delete'));
		$delete->setDescription($translation->_('admin_user_ddelete'));
		
        // Submit
        $submit = new Zend_Form_Element_Submit('submit');
        $submit->setLabel($translation->_('form_save'));

        $this->addElements(array($forename, $lastname, $username, $role, $dateofbirth, $city, $zip, $mail, $homepage, $language, $signature, $threadspp, $postspp, $layout, $password, $groups, $is_active, $activation_code, $delete, $submit));
    }
}  
?>